package com.hockeo.shared.domain.persistent;

import com.extjs.gxt.ui.client.data.BeanModelTag;
import com.hockeo.client.metadata.IMetadataTag;
import com.hockeo.shared.domain.AbstractDomain;
import com.hockeo.tinygds.annotation.TEntity;
import com.hockeo.tinygds.annotation.TId;
import com.hockeo.tinygds.annotation.TName;

/**
 * Represents a hockey association that groups together some leagues.
 *
 * @version $Id$
 * @author jjanke
 */
@TEntity
public class Association extends AbstractDomain<Association, String> implements IMetadataTag, BeanModelTag
{
  @TId
  private String             d_strId;

  @TName( "countries" )
  private String             d_strCountries;

  private transient String[] d_astrCountries;

  /** Argument-less constructor for TinyGDS and GWT/RPC. */
  private Association()
  {}

  public String getCountries()
  {
    return d_strCountries;
  }

  public String[] getCountriesAsArray()
  {
    if ( d_astrCountries == null )
      d_astrCountries = d_strCountries.split( "," );

    return d_astrCountries;
  }

  @Override
  public String getEntityName()
  {
    return "Association";
  }

  @Override
  public String getId()
  {
    return d_strId;
  }
}
